package com.dyzx.hbb.util;

import com.alibaba.fastjson2.JSONObject;


import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

public class SmsUtil {

    private static final String ACCESS_KEY_ID = "LTAI5t7Uvt8VCVew29YcDfog";
    private static final String ACCESS_KEY_SECRET = "3O3M4tJctEbIx6rmZw7N2Xd3Kb0QTX";
    private static final String SIGN_NAME = "成都慧航宝数字科技";
    private static final String TEMPLATE_CODE = "SMS_483725012";

    public static void sendSms(String phoneNumber, String templateParam) throws Exception {
        // 1. 配置 AccessKey
/*        Config config = new Config()
                .setAccessKeyId(ACCESS_KEY_ID) // 替换为真实值
                .setAccessKeySecret(ACCESS_KEY_SECRET) // 替换为真实值
                .setEndpoint("dysmsapi.aliyuncs.com");
        config.endpoint = "dysmsapi.aliyuncs.com";
        config.regionId = "cn-qingdao";

        String templateParam1 = URLEncoder.encode("{\"code\":\"1234\"}", StandardCharsets.UTF_8);
        // 2. 初始化客户端
        com.aliyun.dysmsapi20170525.Client client =
                new com.aliyun.dysmsapi20170525.Client(config);
        String a = URLEncoder.encode("阿里云短信测试", StandardCharsets.UTF_8);
        // 3. 构造请求参数（确保参数编码正确）
        SendSmsRequest sendSmsRequest = new SendSmsRequest()
                .setPhoneNumbers("18099746017")
                .setSignName("阿里云短信测试") // SDK 会自动编码
                .setTemplateCode("SMS_154950909")
                .setTemplateParam("{\"code\":\"1234\"}"); // 直接传入 JSON 字符串

        // 4. 发送请求
        SendSmsResponse response = client.sendSms(sendSmsRequest);
        System.out.println("短信发送结果: " + response.getBody().getMessage());*/
    }

    public static void main(String[] args) throws Exception {
        SmsUtil.sendSms("18099746017", "123456");
    }
}
